<?php
session_start();
include("../include/config.inc.php");
include("../include/version.inc.php");
include("../include/tables.inc.php");
include("../include/funktion.inc.php");
include("../include/rights.inc.php");


if(!isset($_SESSION['userid']))
   weiterleitung("index.php");

$rights = $_SESSION['ses_rights'];
$menu = menu($rights);

if(!check($_SERVER['PHP_SELF'],$rights))
  weiterleitung("uebersicht.php");

$was = $_GET['was'];
$fehler = "";



if($was == "save")
   {
   $auto_eintrag = $_POST['auto_eintrag'];
   $auto_austrag = $_POST['auto_austrag'];

   $betreff_eintrag = $_POST['betreff_eintrag'];
   $mail_eintrag = $_POST['mail_eintrag'];
   $eintrag_modus = $_POST['eintrag_modus'];

   $betreff_austrag = $_POST['betreff_austrag'];
   $mail_austrag = $_POST['mail_austrag'];
   $austrag_modus = $_POST['austrag_modus'];

   mysql_query("UPDATE `$configdb` SET `wert` = '$auto_eintrag' WHERE `feld` = 'auto_eintrag'") or print(mysql_error());
   mysql_query("UPDATE `$configdb` SET `wert` = '$auto_austrag' WHERE `feld` = 'auto_austrag'") or print(mysql_error());

   $config = config();

   mysql_query("UPDATE `$textdb` SET
   `betreff` = '$betreff_eintrag',
   `text` = '$mail_eintrag',
   `modus` = '$eintrag_modus'
   WHERE `name` = 'eintragen'") or print(mysql_error());

   mysql_query("UPDATE `$textdb` SET
   `betreff` = '$betreff_austrag',
   `text` = '$mail_austrag',
   `modus` = '$austrag_modus'
   WHERE `name` = 'austragen'") or print(mysql_error());
   }

$abfrage = "SELECT * FROM `$textdb` WHERE `name` = 'eintragen'";
$ergebnis = mysql_query($abfrage);
$row = mysql_fetch_object($ergebnis);
$mail_eintrag = $row->text;
$betreff_eintrag = $row->betreff;
$eintrag_modus = $row->modus;

$abfrage = "SELECT * FROM `$textdb` WHERE `name` = 'austragen'";
$ergebnis = mysql_query($abfrage);
$row = mysql_fetch_object($ergebnis);
$mail_austrag = $row->text;
$betreff_austrag = $row->betreff;
$austrag_modus = $row->modus;



?>


<html>
<head>
<title>Clanletter - Admin Bereich</title>
<meta name="author" content="Andavos">
<style type="text/css">
<!--
a:hover { text-decoration:none; }

BODY {

     SCROLLBAR-FACE-COLOR: #4F5271;
     SCROLLBAR-HIGHLIGHT-COLOR: #243D62;
    SCROLLBAR-SHADOW-COLOR: rgb(32,32,32);
    SCROLLBAR-ARROW-COLOR: #ffffff;

}

.anhang {
 font-size: 14px;
 color: #000000;
 background-color: #899FBF;

 border-color: #000000;
 border-top-width :1pt;
 border-right-width : 1px;
 border-bottom-width : 1px;
 border-left-width : 1px;
}

-->
</style>


</head>
<body text="#000000" bgcolor="#D0D0D0" link="#000060" alink="#000060" vlink="#000060">


<table cellpadding="5" cellspacing="2"  bgcolor="black" align="center" width="85%">
<tr>
 <td width="205" valign="top" bgcolor="#899FBF"><a target="_blank" href="http://www.php-einfach.de"><img src="php-einfach.jpg" width="199" height="66" border="0" alt="PHP-Einfach.de"></a> <br>


 <?php echo $menu; ?>


<font size="-1"> <a target="_blank" href="http://www.php-einfach.de">&copy; PHP-Einfach.de Clanletter 2.0</a><br>
 </td>
  <td valign="top" bgcolor="#9BAAC1">
<div align="center"><h2>Automatische Emails</h2></div>

<center><font color="#BD0000"><b><?php echo $fehler; ?></b></font></center>



<form action="?was=save" method="post" target="">
<table bgcolor="#000000" cellpadding="5" cellspacing="1" align="center" width="75%">
<tr bgcolor="#314477">
 <th colspan="2"><font color="#ffffff"><b>Automatische Emails</b></font></th>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Automatische Begr&uuml;&szlig;ungsmail:</b></td>
 <td><input type="Radio" name="auto_eintrag" value="0" id="no_ein" <?php ($config['auto_eintrag'] == "1") ? "" : print("checked"); ?>><label for="no_ein"> Nein </label> <br>
 <input type="Radio" name="auto_eintrag" value="1" id="ja_ein" <?php ($config['auto_eintrag'] == "1") ? print("checked") : ""; ?>><label for="ja_ein"> Ja </label>
 </td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Automatische Abschiedsmail:</b></td>
 <td><input type="Radio" name="auto_austrag" value="0" id="no_aus" <?php ($config['auto_austrag'] == "1") ? "" : print("checked"); ?>><label for="no_aus"> Nein </label> <br>
 <input type="Radio" name="auto_austrag" value="1" id="ja_aus" <?php ($config['auto_austrag'] == "1") ? print("checked") : ""; ?>><label for="ja_aus"> Ja </label>
 </td>
</tr>

<tr bgcolor="#314477">
 <th colspan="2"><font color="#ffffff"><b>Eintragen</b></font></th>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Betreff:</b></td>
 <td>
 <input type="Text" name="betreff_eintrag" value="<?php echo htmlentities($betreff_eintrag); ?>" size="40" maxlength="100">
 </td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Mail:</b></td>
 <td>
 <textarea name="mail_eintrag" cols="30" rows="5"><?php echo htmlentities($mail_eintrag); ?></textarea><br>

 <input type="Radio" name="eintrag_modus" value="text" id="text_ein" <?php ($eintrag_modus == "html") ? "" : print("checked"); ?>><label for="text_ein"> Text </label>&nbsp;&nbsp;&nbsp;
 <input type="Radio" name="eintrag_modus" value="html" id="html_ein" <?php ($eintrag_modus == "html") ? print("checked") : ""; ?>><label for="html_ein"> HTML </label>
 </td>
</tr>


<tr bgcolor="#314477">
 <th colspan="2"><font color="#ffffff"><b>Austragen</b></font></th>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Betreff:</b></td>
 <td>
 <input type="Text" name="betreff_austrag" value="<?php echo htmlentities($betreff_austrag); ?>" size="40" maxlength="100">
 </td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Abschiedsmail:</b></td>
 <td>
 <textarea name="mail_austrag" cols="30" rows="5"><?php echo htmlentities($mail_austrag); ?></textarea><br>
 <input type="Radio" name="austrag_modus" value="text" id="text_aus" <?php ($austrag_modus == "html") ? "" : print("checked"); ?>><label for="text_aus"> Text </label>&nbsp;&nbsp;&nbsp;
 <input type="Radio" name="austrag_modus" value="html" id="html_aus" <?php ($austrag_modus == "html") ? print("checked") : ""; ?>><label for="html_aus"> HTML </label>
 </td>
</tr>
</table>


<br>
<center><input type="Submit" name="" value="Speichern"></center>


</form>

  </td>
</tr>
</table>

</body>
</html>
